package com.thinkerwu.learn.core.validator;


import com.thinkerwu.learn.core.enums.BaseEnum;

import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * 判断枚举值是否属于枚举
 *
 * @author Thinker Wu
 */
@Target({ElementType.METHOD, ElementType.FIELD, ElementType.ANNOTATION_TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Constraint(validatedBy = EnumInspectValidator.class)
public @interface EnumInspect {


    /**
     * 枚举的Class,这个字段属于哪个枚举
     *
     * @return
     */
    Class<? extends BaseEnum> enumClass();

    /**
     * 字段值是否必须
     *
     * @return
     */
    boolean required() default false;

    /**
     * 错误提示
     *
     * @return
     */
    String message() default "枚举校验失败";

    /**
     * 分组的内容，自定义校验注解的规定
     *
     * @return
     */
    Class<?>[] groups() default {};

    /**
     * 校验级别，自定义校验注解规定
     *
     * @return
     */
    Class<? extends Payload>[] payload() default {};


}
